package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ProductMoney;
import com.ruoyi.system.service.IProductMoneyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 产品价格
Controller
 * 
 * @author ruoyi
 * @date 2024-07-11
 */
@RestController
@RequestMapping("/product/money")
public class ProductMoneyController extends BaseController
{
    @Autowired
    private IProductMoneyService productMoneyService;

    /**
     * 查询产品价格列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ProductMoney productMoney)
    {
        startPage();
        List<ProductMoney> list = productMoneyService.selectProductMoneyList(productMoney);
        return getDataTable(list);
    }

    /**
     * 导出产品价格列表
     */
    @Log(title = "产品价格", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProductMoney productMoney)
    {
        List<ProductMoney> list = productMoneyService.selectProductMoneyList(productMoney);
        ExcelUtil<ProductMoney> util = new ExcelUtil<ProductMoney>(ProductMoney.class);
        util.exportExcel(response, list, "产品价格数据");
    }

    /**
     * 获取产品价格详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(productMoneyService.selectProductMoneyById(id));
    }

    /**
     * 新增产品价格

     */
    @Log(title = "产品价格", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProductMoney productMoney)
    {
        return toAjax(productMoneyService.insertProductMoney(productMoney));
    }

    /**
     * 修改产品价格

     */
    @Log(title = "产品价格", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProductMoney productMoney)
    {
        return toAjax(productMoneyService.updateProductMoney(productMoney));
    }

    /**
     * 删除产品价格
     */
    @Log(title = "产品价格", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(productMoneyService.deleteProductMoneyByIds(ids));
    }
}
